package com.example.demo.mapper;

import com.example.demo.UserInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Select("select username, `password`, age, gender, phone from userinfo")
    public List<UserInfo> queryAllUser();
    @Select("select username, `password`, age, gender, phone from userinfo where id= #{userid} ")
            UserInfo queryById(@Param("userid") Integer id);

    //@Insert("insert into userinfo (username, `password`, age, gender, phone) values (#{userinfo.username},#{userinfo.password},#{userinfo.age},# {userinfo.gender},#{userinfo.phone})")
    //Integer insert(@Param("userinfo") UserInfo userInfo);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into userinfo (username, age, gender, phone) values (# {userinfo.username},#{userinfo.age},#{userinfo.gender},#{userinfo.phone})")
    Integer insert( UserInfo userInfo);
}
